#include "EvalVisitor.h"
#include "AddExpr.h"
#include "SubExpr.h"
#include "MulExpr.h"
#include "DivExpr.h"
#include "ConstExpr.h"
int EvalVisitor::Getvalue()
{
    return this->m_value;
}
void EvalVisitor::Visit(AddExpr* expr)
{
    expr->Getlhs()->Accept(this);
    int lhsv = this->m_value;
    expr->Getrhs()->Accept(this);
    int rhsv = this->m_value;
    this->m_value = lhsv + rhsv;
};
void EvalVisitor::Visit(SubExpr* expr)
{
    expr->Getlhs()->Accept(this);
    int lhsv = this->m_value;
    expr->Getrhs()->Accept(this);
    int rhsv = this->m_value;
    this->m_value = lhsv - rhsv;
};
void EvalVisitor::Visit(MulExpr* expr)
{
    expr->Getlhs()->Accept(this);
    int lhsv = this->m_value;
    expr->Getrhs()->Accept(this);
    int rhsv = this->m_value;
    this->m_value = lhsv * rhsv;
};
void EvalVisitor::Visit(DivExpr* expr)
{
    expr->Getlhs()->Accept(this);
    int lhsv = this->m_value;
    expr->Getrhs()->Accept(this);
    int rhsv = this->m_value;
    this->m_value = lhsv / rhsv;
};
void EvalVisitor::Visit(ConstExpr* expr)
{
    this->m_value = expr->Getvalue();
};
